package com.yanfan.energy.service.impl;

import java.util.Arrays;
import java.util.List;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.energy.mapper.NjEnergyDeviceDataMapper;
import com.yanfan.energy.domain.NjEnergyDeviceData;
import com.yanfan.energy.service.INjEnergyDeviceDataService;

/**
 * 能耗设备数据Service业务层处理
 *
 * @author genluo
 * @date 2024-10-29
 */
@Service
public class NjEnergyDeviceDataServiceImpl extends ServiceImpl<NjEnergyDeviceDataMapper, NjEnergyDeviceData> implements INjEnergyDeviceDataService {
    @Autowired
    private NjEnergyDeviceDataMapper njEnergyDeviceDataMapper;


    /**
     * 查询能耗设备数据列表
     *
     * @param njEnergyDeviceData 能耗设备数据
     * @return 能耗设备数据
     */
    @Override
    public List<NjEnergyDeviceData> queryPageList(NjEnergyDeviceData njEnergyDeviceData) {
        LambdaQueryWrapper<NjEnergyDeviceData> lqw = buildQueryWrapper(njEnergyDeviceData);
        return njEnergyDeviceDataMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return njEnergyDeviceDataMapper.queryPageList(njEnergyDeviceData);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<NjEnergyDeviceData> buildQueryWrapper(NjEnergyDeviceData bo) {
        LambdaQueryWrapper<NjEnergyDeviceData> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getDeviceType()), NjEnergyDeviceData::getDeviceType, bo.getDeviceType());
        lqw.like(StringUtils.isNotBlank(bo.getDeviceName()), NjEnergyDeviceData::getDeviceName, bo.getDeviceName());
        lqw.orderByDesc(NjEnergyDeviceData ::getUpdateTime);
        return lqw;
    }



}
